% 负荷曲线抽样测试脚本
file_name = compose('%s/load Profiles/Load_profile_%d.csv',getWorkPath(), (1:100).');
ratedPQs.P=[10 20 30].';
ratedPQs.Q = [12 22 32].';
ratedPQs.users=[5 6 7].';
ratedPQtable = struct2table(ratedPQs);
X=[0:12;1:13;10:22].';
X=duration(X);

[PQcurve1, SampleInfo] = LoadAllocate(file_name, ratedPQtable, X);
[PQcurve2, SampleInfo] = LoadAllocate(SampleInfo, ratedPQtable, X);


sum_diff=0;
for k=1:3
    diff=PQcurve1{k}-PQcurve2{k};
    sum_diff=sum_diff+sum(abs(diff(:)));
end
fprintf("插值绝对相差%f\n",sum_diff);

f1=@()(LoadAllocate(file_name, ratedPQtable, X));
f2=@()(LoadAllocate(SampleInfo, ratedPQtable, X));
t = timeit(f1,2);
fprintf("读取曲线获取曲线耗时%f秒\n",t);
t = timeit(f2,2);
fprintf("从已有结构体获取曲线耗时%f秒\n",t);